///Project: Introducing GLP Paper Table 4 
///Date:14 09 2018 
///Stata14 


********TABLE 4*************
***Row1:>educational Attainment***
clear all
use "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/GLP_person_18 07 29.dta"
drop if edulevel==0
preserve
collapse (mean) edulevel=edulevel, by(country country_nid) //to see number of countries
sum edulevel
restore
**Apex**
preserve
keep if power==1
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
restore
**Top Ten**
preserve
keep if power==3
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
restore
**Cabinet**
preserve
keep if office1==2|office2==2|office3==2
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
restore
**Supreme Court***
preserve
keep if office1==7|office2==7|office3==7
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
restore
**MPs**
preserve
keep if office1==6|office2==6|office3==6
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
restore
**Wealth**
*nonOECD*
preserve
keep if wealth==0
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
restore
*OECD*
preserve
keep if wealth==1
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
restore
**Regime**
*Democracy*
preserve
keep if regime==0
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
restore
*nondemocracy*
preserve
keep if regime==1
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
restore
*Regions
preserve
collapse (mean) edulevel =edulevel, by(region country_nid)
by region, sort: sum edulevel
restore

***Row 2: Edu Abroad***
clear all
use "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/GLP_person_18 07 29.dta"
drop if person_abroad==.
gen eduabroad=0
replace eduabroad=1 if person_abroad==1
gen eduhome=0
replace eduhome=1 if person_abroad==0
sort country_nid
//Descriptive
count
preserve
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
restore
*Apex*
preserve
keep if power==1
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
restore
*Top Ten*
preserve
keep if power==3
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
restore
*Cabinet*
preserve
keep if office1==2 |office2==2| office3==2
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7| office3==7
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
restore
*MPs*
preserve
keep if office1==6 |office2==6| office3==6
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
sort total
restore
**Wealth/Region/Regime**
preserve
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (wealth regime region country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
sort country_nid
sum prcabroad if wealth==0
sum prcabroad if wealth==1
sum prcabroad if regime==0
sum prcabroad if regime==1
by region, sort: sum  prcabroad
restore

***Row 3: Edu in West***
clear all
use "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/GLP_person_18 07 29.dta"
sort person_nid 
drop if person_eduwest==.
gen eduwest=0
replace eduwest=1 if person_eduwest==1
gen eduhome=0
replace eduhome=1 if person_eduwest==0
sort country_nid
preserve
count
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
sort prcwest
restore
*Apex*
preserve
keep if power==1
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
restore
*Top Ten*
preserve
keep if power==3
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
restore
*Cabinet*
preserve
keep if office1==2 |office2==2| office3==2
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7| office3==7
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
restore
*MPs*
preserve
keep if office1==6 |office2==6| office3==6
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
restore
**Wealth/Region/Regime**
preserve
collapse (sum) eduwest=eduwest eduhome=eduhome, by (regime region wealth country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sort country_nid
sum prcwest if wealth==0
sum prcwest if wealth==1
sum prcwest if regime==0
sum prcwest if regime==1
by region, sort: sum  prcwest
restore


***Rows:Disciplines 11***
clear all
use "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/GLP_person_18 07 29.dta"
/*1	"agronomy"
2"economics / business / management"
3"engineering"
4"mathematics / computer science"
5"biology/chemistry/physics"
6"humanities"
7"social sciences"
8"law"
9"medicine"
10"military"
11"other"*/
gen temp=1
//drop if edumajor1==0
count
count if power==1
count if power==3
count if office1==2|office2==2|office3==2
count if office1==7|office2==7|office3==7
count if office1==6|office2==6|office3==6
count if wealth==0
count if wealth==1
count if region==1
count if region==2
count if region==3
count if region==4
count if region==5
count if regime==0
count if regime==1

**Agronomy**
preserve
sort country_nid
by country_nid: egen agron=total(temp) if edumajor1==1
by country_nid: egen alldegrees=total(temp)
gen percentage=agron/alldegrees*100
keep if agron<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/145
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen agron=total(temp) if edumajor1==1
by country_nid: egen alledu=total(temp)
gen percentage=agron/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen agron=total(temp) if edumajor1==1
by country_nid: egen alledu=total(temp)
gen percentage=agron/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen agron=total(temp) if edumajor1==1
by country_nid: egen alledu=total(temp)
gen percentage=agron/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen agron=total(temp) if edumajor1==1
by country_nid: egen alledu=total(temp)
gen percentage=agron/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen agron=total(temp) if edumajor1==1
by country_nid: egen alledu=total(temp)
gen percentage=agron/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
///////////////////////////////////////////////////////////////////
**Econ/Bus/Man**
preserve
sort country_nid
by country_nid: egen econ=total(temp) if edumajor1==2
by country_nid: egen alldegrees=total(temp)
gen percentage=econ/alldegrees*100
keep if econ<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen econ=total(temp) if edumajor1==2
by country_nid: egen alledu=total(temp)
gen percentage=econ/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen econ=total(temp) if edumajor1==2
by country_nid: egen alledu=total(temp)
gen percentage=econ/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen econ=total(temp) if edumajor1==2
by country_nid: egen alledu=total(temp)
gen percentage=econ/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen econ=total(temp) if edumajor1==2
by country_nid: egen alledu=total(temp)
gen percentage=econ/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen econ=total(temp) if edumajor1==2
by country_nid: egen alledu=total(temp)
gen percentage=econ/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
////////////////////////////////////////////
**Engineering**
preserve
sort country_nid
by country_nid: egen eng=total(temp) if edumajor1==3
by country_nid: egen alldegrees=total(temp)
gen percentage=eng/alldegrees*100
keep if eng<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen eng=total(temp) if edumajor1==3
by country_nid: egen alledu=total(temp)
gen percentage=eng/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen eng=total(temp) if edumajor1==3
by country_nid: egen alledu=total(temp)
gen percentage=eng/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen eng=total(temp) if edumajor1==3
by country_nid: egen alledu=total(temp)
gen percentage=eng/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen eng=total(temp) if edumajor1==3
by country_nid: egen alledu=total(temp)
gen percentage=eng/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen eng=total(temp) if edumajor1==3
by country_nid: egen alledu=total(temp)
gen percentage=eng/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
//////////////////////////////////////////////////
**Math-CS**
preserve
sort country_nid
by country_nid: egen math=total(temp) if edumajor1==4
by country_nid: egen alldegrees=total(temp)
gen percentage=math/alldegrees*100
keep if math<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen math=total(temp) if edumajor1==4
by country_nid: egen alledu=total(temp)
gen percentage=math/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen math=total(temp) if edumajor1==4
by country_nid: egen alledu=total(temp)
gen percentage=math/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen math=total(temp) if edumajor1==4
by country_nid: egen alledu=total(temp)
gen percentage=math/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen math=total(temp) if edumajor1==4
by country_nid: egen alledu=total(temp)
gen percentage=math/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen math=total(temp) if edumajor1==4
by country_nid: egen alledu=total(temp)
gen percentage=math/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
//////////////////////////////////////////////////
**Bio/Chem/Phys**
preserve
sort country_nid
by country_nid: egen bio=total(temp) if edumajor1==5
by country_nid: egen alldegrees=total(temp)
gen percentage=bio/alldegrees*100
keep if bio<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen bio=total(temp) if edumajor1==5
by country_nid: egen alledu=total(temp)
gen percentage=bio/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen bio=total(temp) if edumajor1==5
by country_nid: egen alledu=total(temp)
gen percentage=bio/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen bio=total(temp) if edumajor1==5
by country_nid: egen alledu=total(temp)
gen percentage=bio/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen bio=total(temp) if edumajor1==5
by country_nid: egen alledu=total(temp)
gen percentage=bio/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen bio=total(temp) if edumajor1==5
by country_nid: egen alledu=total(temp)
gen percentage=bio/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
//////////////////////////////////////////////////
**Humanities**
preserve
sort country_nid
by country_nid: egen humanities=total(temp) if edumajor1==6
by country_nid: egen alldegrees=total(temp)
gen percentage=humanities/alldegrees*100
keep if humanities<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen humanities=total(temp) if edumajor1==6
by country_nid: egen alledu=total(temp)
gen percentage=humanities/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen humanities=total(temp) if edumajor1==6
by country_nid: egen alledu=total(temp)
gen percentage=humanities/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen humanities=total(temp) if edumajor1==6
by country_nid: egen alledu=total(temp)
gen percentage=humanities/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen humanities=total(temp) if edumajor1==6
by country_nid: egen alledu=total(temp)
gen percentage=humanities/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen humanities=total(temp) if edumajor1==6
by country_nid: egen alledu=total(temp)
gen percentage=humanities/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
/////////////////////////////////////////////////
**Social Sciences**
preserve
sort country_nid
by country_nid: egen socsci=total(temp) if edumajor1==7
by country_nid: egen alldegrees=total(temp)
gen percentage=socsci/alldegrees*100
keep if socsci<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen socsci=total(temp) if edumajor1==7
by country_nid: egen alledu=total(temp)
gen percentage=socsci/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen socsci=total(temp) if edumajor1==7
by country_nid: egen alledu=total(temp)
gen percentage=socsci/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen socsci=total(temp) if edumajor1==7
by country_nid: egen alledu=total(temp)
gen percentage=socsci/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen socsci=total(temp) if edumajor1==7
by country_nid: egen alledu=total(temp)
gen percentage=socsci/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen socsci=total(temp) if edumajor1==7
by country_nid: egen alledu=total(temp)
gen percentage=socsci/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
////////////////////////////////////////
**Law degree**
preserve
sort country_nid
by country_nid: egen law=total(temp) if edumajor1==8
by country_nid: egen alldegrees=total(temp)
gen percentage=law/alldegrees*100
keep if law<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen law=total(temp) if edumajor1==8
by country_nid: egen alledu=total(temp)
gen percentage=law/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen law=total(temp) if edumajor1==8
by country_nid: egen alledu=total(temp)
gen percentage=law/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen law=total(temp) if edumajor1==8
by country_nid: egen alledu=total(temp)
gen percentage=law/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen law=total(temp) if edumajor1==8
by country_nid: egen alledu=total(temp)
gen percentage=law/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen law=total(temp) if edumajor1==8
by country_nid: egen alledu=total(temp)
gen percentage=law/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
///////////////////////////////////////////
**Medicine**
preserve
sort country_nid
by country_nid: egen med=total(temp) if edumajor1==9
by country_nid: egen alldegrees=total(temp)
gen percentage=med/alldegrees*100
keep if med<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen med=total(temp) if edumajor1==9
by country_nid: egen alledu=total(temp)
gen percentage=med/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen med=total(temp) if edumajor1==9
by country_nid: egen alledu=total(temp)
gen percentage=med/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen med=total(temp) if edumajor1==9
by country_nid: egen alledu=total(temp)
gen percentage=med/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen med=total(temp) if edumajor1==9
by country_nid: egen alledu=total(temp)
gen percentage=med/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen med=total(temp) if edumajor1==9
by country_nid: egen alledu=total(temp)
gen percentage=med/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
///////////////////////////////////////////////////////////
**Military**
preserve
sort country_nid
by country_nid: egen military=total(temp) if edumajor1==10
by country_nid: egen alldegrees=total(temp)
gen percentage=military/alldegrees*100
keep if military<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen mil=total(temp) if edumajor1==10
by country_nid: egen alledu=total(temp)
gen percentage=mil/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen mil=total(temp) if edumajor1==10
by country_nid: egen alledu=total(temp)
gen percentage=mil/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen mil=total(temp) if edumajor1==10
by country_nid: egen alledu=total(temp)
gen percentage=mil/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen mil=total(temp) if edumajor1==10
by country_nid: egen alledu=total(temp)
gen percentage=mil/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen mil=total(temp) if edumajor1==10
by country_nid: egen alledu=total(temp)
gen percentage=mil/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
/////////////////////////////////////////////
**Other**
preserve
sort country_nid
by country_nid: egen other=total(temp) if edumajor1==11
by country_nid: egen alldegrees=total(temp)
gen percentage=other/alldegrees*100
keep if other<.
duplicates drop country_nid, force
merge m:1 country_nid using "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta"
ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta
/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submi
> ssion 2 (Bernhard)/Round 3/Replicationdata/Country_list.dta

replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/146
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum  percentage
restore
*Apex*
preserve
keep if power==1
sort country_nid
by country_nid: egen other=total(temp) if edumajor1==11
by country_nid: egen alledu=total(temp)
gen percentage=other/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top Ten*
preserve
keep if power==3
sort country_nid
by country_nid: egen other=total(temp) if edumajor1==11
by country_nid: egen alledu=total(temp)
gen percentage=other/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
sort country_nid
by country_nid: egen other=total(temp) if edumajor1==11
by country_nid: egen alledu=total(temp)
gen percentage=other/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court* 
preserve
keep if office1==7 |office2==7 |office3==7
sort country_nid
by country_nid: egen other=total(temp) if edumajor1==11
by country_nid: egen alledu=total(temp)
gen percentage=other/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs
preserve
keep if office1==6 |office2==6 |office3==6
sort country_nid
by country_nid: egen other=total(temp) if edumajor1==11
by country_nid: egen alledu=total(temp)
gen percentage=other/alledu*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
